import 'package:flutter/material.dart';
import 'package:flutter_study/project/_02douban/model/home_model.dart';
import 'package:flutter_study/project/_02douban/pages/home/home_movie_item.dart';
import 'package:flutter_study/project/_02douban/service/home_request.dart';

class HomeContent extends StatefulWidget {
  @override
  _HomeContentState createState() => _HomeContentState();
}

class _HomeContentState extends State<HomeContent> {
  List<MovieItem> movieList = [];

  // 从网络获取数据
  @override
  void initState() {
    super.initState();
    HomeRequest.getMovieListByFile(0).then((value) {
      setState(() {
        print('value = $value');
        movieList = value;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: ListView.builder(
        itemBuilder: (ctx, index) {
          return HomeMovieItem(movieList[index]);
        },
        itemCount: movieList.length,
      ),
    );
  }
}
